import java.awt.Graphics;
import java.awt.Point;
import java.io.File;
import java.io.IOException;
import java.util.Random;

import javax.imageio.ImageIO;

/**
 * A kaja osztaly, mely a kigyo elesegeit allitja elo.
 */
public class Food {
	private Random rn = new Random();
	private Random gyn = new Random();
	private String gyumolcs = new String("res\\food\\eper.png");
	private int gyx = rn.nextInt(66)*SnakeC.SIZE;
	private int gyy = rn.nextInt(40)*SnakeC.SIZE;
	private Snake snake;
	
	public Food(){
		snake = new Snake();
	}
	
	/**
	 * Kirajzolja a megfelelo kajat a grafikus feluletre.
	 */
	public void drawFood(Graphics g) throws IOException {
		g.drawImage(ImageIO.read(new File(gyumolcs)), gyx, gyy, null);		
	}
	
	/**
	 * Veletlen szamok segitsegevel general a kajanak kordinatakat.
	 * Majd szinten veletlen szam generalassal kivalasztja az uj kaja tipusat.
	 * 
	 */
	public void ujkaja(){
		do {
			gyx = rn.nextInt(66)*SnakeC.SIZE;
			gyy = rn.nextInt(40)*SnakeC.SIZE;
		} while (snake.megfelel(new Point(gyx, gyy)) == false);
		
		int gyumolcsszam = gyn.nextInt(7);
		switch (gyumolcsszam){
			case 0: gyumolcs = "res\\food\\alma.png"; break;
			case 1: gyumolcs = "res\\food\\dinye.png"; break;
			case 2: gyumolcs = "res\\food\\eper.png"; break;
			case 3: gyumolcs = "res\\food\\hamburger.png"; break;
			case 4: gyumolcs = "res\\food\\hus.png"; break;
			case 5: gyumolcs = "res\\food\\torta.png"; break;
			case 6: gyumolcs = "res\\food\\banan.png"; break;
		}
	}
	
	/**
	 * Visszateriti a kaja aktualis poxiciojat, x es y koordinatakat.
	 */
	public Point getFood(){
		return new Point(gyx,gyy);
	}
}
